package com.controller;

import com.mapper.SystemNoticeMapper;
import com.model.SystemNotice;
import com.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.stereotype.Controller;

import javax.annotation.PostConstruct;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import java.util.List;

@Controller
public class MyApplicationController implements ServletContextInitializer {


    @Autowired
    SystemNoticeMapper systemNoticeMapper;

    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {

        System.out.println("onStartup......");
        List<SystemNotice> noticeList = systemNoticeMapper.getSystemNoticeByCondition();
        servletContext.setAttribute("referenceData",noticeList);

        servletContext.setAttribute("currentTime", DateUtils.getFormtDate());
    }


}

